{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Probability Sampling\n",
    "\n",
    "Unlike convenience sampling, probability sampling allows us to assign a precise\n",
    "probability to the event that we draw a particular sample. We will begin by\n",
    "reviewing simple random samples from Data 8, then introduce two alternative\n",
    "methods of probability sampling: cluster sampling and stratified sampling.\n",
    "\n",
    "Suppose we have a population of $6$ individuals. We've given each individual a\n",
    "different letter from $A-F$."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Simple Random Sample (SRS)\n",
    "\n",
    "To take an simple random sample of size $2$ from this population, we can write\n",
    "each letter $A-F$ on a single index card, place all the cards into a hat, mix\n",
    "the cards well, and draw $2$ cards without looking. That is, a SRS is sampling\n",
    "uniformly at random without replacement.\n",
    "\n",
    "Here are all possible samples of size 2:\n",
    "\n",
    "$$\n",
    "\\begin{matrix}\n",
    "AB & BC & CD & DE & EF\\\\\\\\\n",
    "AC&BD&CE&DF&\\\\\\\\\n",
    "AD&BE&CF&&\\\\\\\\\n",
    "AE&BF&&&\\\\\\\\\n",
    "AF&&&&\\\\\\\\\n",
    "\\end{matrix}\n",
    "$$\n",
    "\n",
    "There are $15$ possible samples of size $2$ from our population of $6$. Another\n",
    "way to count the number of possible samples is:\n",
    "\n",
    "$$\n",
    "\\binom{6}{2} = \\frac{6!}{2!4!} = 15\n",
    "$$\n",
    "\n",
    "Since in a SRS we sample uniformly at random, each of these $15$ samples are\n",
    "equally likely to be chosen:\n",
    "\n",
    "$$ P(AB) = P(CD) = \\ldots = P(DF) = \\frac{1}{15} $$\n",
    "\n",
    "We can also use this chance mechanism to answer other questions about the\n",
    "composition of the sample. For example:\n",
    "\n",
    "$$ P(A \\text{ in sample}) = \\frac{5}{15} = \\frac{1}{3}$$\n",
    "\n",
    "Since $5$ out of $15$ of the possible samples listed above contain $A$.\n",
    "\n",
    "By symmetry, we can say:\n",
    "\n",
    "$$ P(A \\text{ in sample}) = P(F \\text{ in sample}) = \\frac{1}{3} $$\n",
    "\n",
    "Another way of computing $ P(A \\text{ in sample}) $ is to recognize that for\n",
    "$A$ to be in the sample, we either need to draw it as the first card or as\n",
    "the second card.\n",
    "\n",
    "$$\n",
    "\\begin{aligned}\n",
    "P(A \\text{ in sample}) &= P(\\text{A is first or A is second}) \\\\\\\\\n",
    "&= P(\\text{A is first}) + P(\\text{A is second}) \\\\\\\\\n",
    "&= \\frac{1}{6} \\cdot \\frac{5}{5} + \\frac{5}{6} \\cdot \\frac{1}{5} \\\\\\\\\n",
    "&= \\frac{1}{3} \\\\\\\\\n",
    "\\end{aligned}\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Cluster Sampling\n",
    "\n",
    "In cluster sampling, we divide the population into clusters. Then, we use SRS\n",
    "to select clusters at random instead of individuals.\n",
    "\n",
    "As an example, suppose we take our population of $6$ individuals and we pair\n",
    "each of them up: $ (A,B)\\quad (C,D) \\quad (E,F) $ to form 3 clusters of 2\n",
    "individuals. Then, we use SRS to select one cluster to produce a sample of size 2.\n",
    "\n",
    "As before, we can compute the probability that $A$ is in our sample:\n",
    "\n",
    "$$ P(A \\text{ in sample}) = P(AB \\text{ drawn}) = \\frac{1}{3} $$\n",
    "\n",
    "Similarly the probability that any particular person appears in our sample is\n",
    "$\\frac{1}{3}$. Note that this is the same as our SRS. However, we see\n",
    "differences when we look at the samples themselves. For example, in a SRS the\n",
    "chance of getting $AB$ is the same as the chance of getting $AC$:\n",
    "$\\frac{1}{15}$. However, with this cluster sampling scheme:\n",
    "\n",
    "$$\n",
    "\\begin{aligned}\n",
    "P(AB) &= \\frac{1}{3} \\\\\\\\\n",
    "P(AC) &= 0\n",
    "\\end{aligned}\n",
    "$$\n",
    "\n",
    "Since $A$ and $C$ can never appear in the same sample if we only select one\n",
    "cluster.\n",
    "\n",
    "Cluster sampling is still probability sampling since we can assign a\n",
    "probability to each potential sample. However, the resulting probabilities are\n",
    "different than using a SRS depending on how the population is clustered.\n",
    "\n",
    "Why use cluster sampling? Cluster sampling is most useful because it makes\n",
    "sample collection easier. For example, it is much easier to poll towns of 100\n",
    "people each than to poll thousands of people distributed across the entire US.\n",
    "This is the reason why many polling agencies today use forms of cluster\n",
    "sampling to conduct surveys.\n",
    "\n",
    "The main downside of cluster sampling is that it tends to produce greater\n",
    "variation in estimation. This typically means that we take larger samples when\n",
    "using cluster sampling. Note that the reality is much more complicated than\n",
    "this, but we will leave the details to a future course on sampling techniques."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Stratified Sampling\n",
    "\n",
    "In stratified sampling, we divide the population into strata, and then produce\n",
    "one simple random sample per strata. In both cluster sampling and stratified\n",
    "sampling we split the population into groups; in cluster sampling we use a\n",
    "single SRS to select groups whereas in stratified sampling we use multiple\n",
    "SRS's, one for each group.\n",
    "\n",
    "We can divide our population of 6 individuals into the following strata:\n",
    "\n",
    "$$\n",
    "\\begin{matrix}\n",
    "\\text{Strata 1:} & \\{A,B,C,D\\} \\\\\\\\\n",
    "\\text{Strata 2:} & \\{E,F\\}\n",
    "\\end{matrix}\n",
    "$$\n",
    "\n",
    "We use an SRS to select one individual from each strata to produce a sample of\n",
    "size $2$. This gives us the following possible samples:\n",
    "\n",
    "$$\n",
    "\\begin{aligned}\n",
    "(A,E)\\quad (A,F) \\quad (B,E) \\quad (B,F) \\quad (C,E) \\quad (C,F)\n",
    "\\quad (D,E) \\quad (D,F)\n",
    "\\end{aligned}\n",
    "$$\n",
    "\n",
    "Again, we can compute the probability that $A$ is in our sample:\n",
    "\n",
    "$$\n",
    "\\begin{aligned}\n",
    "P(A \\text{ in sample}) &= P(A \\text{ selected from Strata 1}) \\\\\\\\\n",
    "&= \\frac{1}{4}\n",
    "\\end{aligned}\n",
    "$$\n",
    "\n",
    "However:\n",
    "\n",
    "$$\n",
    "\\begin{aligned}\n",
    "P(AB) &= 0\n",
    "\\end{aligned}\n",
    "$$\n",
    "\n",
    "since $A$ and $B$ cannot appear in the same sample.\n",
    "\n",
    "Like cluster sampling, stratified sampling is also a probability sampling\n",
    "method that produces different probabilities depending on the stratification of\n",
    "the population. Note that like this example, the strata do not have to be the\n",
    "same size. For example, we can stratify the US by occupation, then take samples\n",
    "from each strata of size proportional to the distribution of occupations in the\n",
    "US — if only 0.01% of people in the US are statisticians, we can ensure that\n",
    "0.01% of our sample will be composed of statisticians. A simple random sample\n",
    "might miss the poor statisticians altogether!\n",
    "\n",
    "As you may have figured out, stratified sampling can perhaps be called the\n",
    "proper way to conduct quota sampling. It allows the researcher to ensure that\n",
    "subgroups of the population are well-represented in the sample without using\n",
    "human judgement to select the individuals in the sample. This can often result\n",
    "in less variation in estimation. However, stratified sampling is sometimes more\n",
    "difficult to accomplish because we sometimes don't know how large each strata\n",
    "is. In the previous example we have the advantage of the US census, but other\n",
    "times we are not so fortunate."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Why Probability Sampling?\n",
    "\n",
    "As we have seen in Data 8, probability sampling enables us to quantify our\n",
    "uncertainty about an estimation or prediction. It is only through this\n",
    "precision that we can conduct inference and hypothesis testing. Be wary when\n",
    "anyone gives you p-values or confidence levels without a proper explanation of\n",
    "their sampling techniques.\n",
    "\n",
    "Now that we understand probability sampling let us see how the humble SRS\n",
    "compares against \"big data\"."
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
